import { RankBaseItem } from "./RankBaseItem";
import { Cache } from "../../cache/Cache";
import { GTextFormat } from "../../../common/GTextFormat";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { TToplist } from "../../../../Message/Db/Tables/TToplist";
import { GameDefConfig } from "../../resource/GameDefConfig";
import { ColorConfig } from "../../resource/ColorConfig";
import { CareerConfig } from "../../resource/CareerConfig";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { Language } from "../../../../extend/language/Language";
type int = number;
//class FlowerRankItem
    
    export  class FlowerRankItem extends RankBaseItem
    {
        constructor()
        {
            super();
            this.init();
            _serverId = Cache.instance.ranking.serverId;
            mouseChildren = false;
            return;
        }

        /* internal  */init(): void
        {
            this._tf = new GTextFormat("", 12, 11661311, false, false, false, null, null, flash.text.TextFormatAlign.CENTER);
            this._rankTxt = this.createTextField("", 0, 0, 25, 33, this._tf);
            this._nameTxt = this.createTextField("", 27, 0, 90, 33, this._tf);
            this._campTxt = this.createTextField("", 120, 0, 35, 33, this._tf);
            this._careerTxt = this.createTextField("", 155, 0, 75, 33, this._tf);
            this._gloryTxt = this.createTextField("", 205, 0, 125, 33, this._tf);
            this._charmTxt = this.createTextField("", 325, 0, 50, 33, this._tf);
            this._rangeTxt = this.createTextField("", 375, 0, 120, 33, this._tf);
            this._bitmap = new Object /* flash.display.Bitmap */();
            var loc1=ObjCreate.createBg(0, 25, 460, 2, this, ImagesConst.SplitLine);
            return;
        }

        /* internal  */createTextField(arg1: string, arg2: int, arg3: int, arg4: int, arg5: int, arg6: Object /* flash.text.TextFormat */): Object /* flash.text.TextField */
        {
            var loc1;
            (loc1 = new Object /* flash.text.TextField */()).text = arg1;
            loc1.x = arg2;
            loc1.y = arg3;
            loc1.width = arg4;
            loc1.height = arg5;
            loc1.selectable = false;
            loc1.setTextFormat(arg6);
            addChild(loc1);
            return loc1;
        }

        public updateItem(arg1: TToplist): void
        {
            var loc8=null;
            if (arg1 == null) 
            {
                this._rankTxt.text = "";
                this._nameTxt.text = "";
                this._campTxt.text = "";
                this._careerTxt.text = "";
                this._gloryTxt.text = "";
                this._charmTxt.text = "";
                this._rangeTxt.text = "";
                _sEntityId = null;
                _sMiniPlayer = null;
                if (this._bitmap.parent) 
                {
                    removeChild(this._bitmap);
                }
                clearBgColor();
                return;
            }
            _data = arg1;
            var loc1=_data.rank;
            this._rankTxt.text = loc1.toString();
            this._rankTxt.setTextFormat(this._tf);
            this._nameTxt.text = _data.entityName;
            this._nameTxt.setTextFormat(this._tf);
            var loc2=_data.propertyOne;
            this._campTxt.text = GameDefConfig.instance.getECamp(loc2);
            var loc3=ColorConfig.instance.getCountryColor(loc2).intColor;
            var loc4=new GTextFormat("", 12, loc3, false, false, false, null, null, flash.text.TextFormatAlign.CENTER);
            this._campTxt.setTextFormat(loc4);
            var loc5=_data.propertyThree;
            var loc6=CareerConfig.instance.getInfoByCode(loc5).name;
            this._careerTxt.text = loc6;
            this._careerTxt.setTextFormat(this._tf);
            this._gloryTxt.text = "--";
            this._gloryTxt.setTextFormat(this._tf);
            this._charmTxt.text = _data.valueOne.toString();
            this._charmTxt.setTextFormat(this._tf);
            if (this._bitmap.parent) 
            {
                removeChild(this._bitmap);
            }
            var loc7=_data.lastRank;
            var loc9=true;
            if (loc7 != 0) 
            {
                if (loc1 > loc7) 
                {
                    this._bitmap = GlobalClass.getBitmap(ImagesConst.RangeDecline);
                    loc8 = (loc1 - loc7).toString();
                }
                else if (loc1 < loc7) 
                {
                    this._bitmap = GlobalClass.getBitmap(ImagesConst.RangeRaise);
                    loc8 = (loc7 - loc1).toString();
                }
                else if (loc1 == loc7) 
                {
                    this._bitmap = GlobalClass.getBitmap(ImagesConst.RangeSame);
                    loc8 = "";
                }
            }
            else 
            {
                loc9 = false;
                loc8 = Language.getString(32078);
            }
            if (loc9) 
            {
                this._bitmap.x = 418;
                this._bitmap.y = 2;
                addChild(this._bitmap);
            }
            this._rangeTxt.text = loc8.toString();
            this._rangeTxt.setTextFormat(this._tf);
            initPlayerMenuInfo();
            return;
        }

        /* internal */ /* var */_tf: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_rankTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_campTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_careerTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_gloryTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_charmTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_rangeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_bitmap: Object /* flash.display.Bitmap */;
    }
